home *** CD-ROM | disk | FTP | other *** search
/ Mac Cube 4: Multimedia Applications / MacCube Volume 4: Multimedia Applications.iso / Graphics / NIH Image Folder / Macros / Video < prev   
Text File  |  1993-07-14  |  5KB  |  198 lines

  1. procedure ExtractEvenField(NewWindow:boolean);
  2. {
  3. Replaces odd scan lines with average of neighboring even lines. Can be used to improve the quality of images that have even and odd fields that are out of sync as the result of subject movement during capture.
  4. }
  5. var
  6.   i,width,height,row1,row2:integer;
  7. begin
  8.   SaveState;
  9.   if NewWindow then Duplicate('Even Field');
  10.   GetPicSize(width,height);
  11.   row1:=0; row2:=0;
  12.   for i:=1 to height/2 do begin
  13.     GetRow(0,row1,width);
  14.     PutRow(0,row2,width);
  15.     row1:=row1+2;
  16.     row2:=row2+1;
  17.   end;
  18.   MakeRoi(0,0,width,height/2);
  19.   Copy;
  20.   MakeRoi(0,height/4-1,width,height/2);
  21.   Paste;
  22.   RestoreRoi;
  23.   SetScaling('Bilinear; Same Window');
  24.   ScaleAndRotate(1,2,0);
  25.   RestoreState;
  26. end;
  27.  
  28. macro 'Extract Even Field->New Window';
  29. begin
  30.   ExtractEvenField(true);
  31. end;
  32.  
  33. macro 'Extract Even Field->Same Window';
  34. begin
  35.   ExtractEvenField(false);
  36. end;
  37.  
  38.  
  39. macro 'Make Movie to Disk…';
  40. {
  41. Captures a specified number of images at a specified rate and
  42. saves them to disk. Select an area of interest within the Camera
  43. window before starting. Can be aborted with cmd-period.
  44. }
  45. var
  46.   nFrames,n,Left,Top,Width,Height:integer;
  47.   IntervalTicks,EndTicks,secs:integer;
  48. begin
  49.   RequiresVersion(1.49);
  50.   GetRoi(Left,Top,Width,Height);
  51.   if width=0 then begin
  52.     PutMessage('First select the area of interest in the Camera window.');
  53.     exit;
  54.   end;
  55.   nFrames:=GetNumber('Number of Frames?',10);
  56.   IntervalTicks:=round(GetNumber('Delay Between Frames(seconds)?',60)*60);
  57.   EndTicks:=TickCount+IntervalTicks;
  58.   for n:=1 to nFrames do begin
  59.     StopCapturing;
  60.     MakeRoi(Left,Top,Width,Height);
  61.     SaveAs('Frame ',n);
  62.     StartCapturing;
  63.     while TickCount<EndTicks do begin
  64.       secs:=(EndTicks-TickCount) div 60;
  65.       ShowMessage(n:1,'/',nFrames,' ',secs:4)
  66.     end;
  67.     EndTicks:=EndTicks+IntervalTicks;
  68.     beep;
  69.   end;
  70.   StopCapturing;
  71. end;
  72.  
  73.  
  74. macro 'Camera and Light Source Test…';
  75.   {Use to test cameras and light sources for temporal stability.}
  76. var
  77.   delay,nFrames:integer;
  78.   i:real;
  79. begin
  80.    nFrames:=trunc(GetNumber('Number of Frames:',10));
  81.    delay:=trunc(GetNumber('Delay in seconds:',10));
  82.    for I:=1 to nFrames do begin
  83.      Capture;
  84.      Measure;
  85.      wait(delay);
  86.   end;
  87. end;
  88.  
  89.  
  90. macro 'Average Frames [A]';
  91. begin
  92.   AverageFrames;
  93. end;
  94.  
  95.  
  96. macro 'Average Frames on Trigger';
  97. begin
  98.   WaitForTrigger;
  99.   AverageFrames;
  100. end;
  101.  
  102.  
  103. macro 'Capture Frames…';
  104. var
  105.   left,top,width,height,n,Camera,nFrames:integer;
  106. begin
  107.   GetRoi(left,top,width,height);
  108.   if width=0 then begin
  109.     PutMessage('Please select an area of interest in the Camera window.');
  110.     exit;
  111.   end;
  112.   nFrames:=GetNumber('Number of frames:',4);
  113.   StartCapturing;
  114.   Camera:=nPics;
  115.   n:=0;
  116.   repeat
  117.     if Button then begin
  118.       MakeRoi(left,top,width,height);
  119.       n:=n+1;
  120.       Duplicate('Frame ',n:1);
  121.       SelectPic(Camera);
  122.       StartCapturing;
  123.     end;
  124.   until n=nFrames;
  125.   StopCapturing;
  126.   Dispose;
  127.   SetOption; TileWindows;
  128. end;
  129.  
  130.  
  131. macro 'Dynamic 1-D Plot';
  132. {
  133. Displays a dynamic 1-d plot of a line in the image while the image
  134. is being captured. You most first create a line selection in
  135. Camera window. The macro works best if you first to a Plot Profile
  136. and move the Plot window so it doesn't cover the Camera window. You
  137. may have to resize the Camera window. Hold down the mouse button
  138. to terminate.
  139. }
  140. var
  141.   x1,y1,x2,y2,LineWidth:integer;
  142. begin
  143.   GetLine(x1,y1,x2,y2,LineWidth);
  144.   if x1=-1 then begin
  145.     PutMessage('Create a straight line selection in the Camera window');
  146.     exit;
  147.   end;
  148.   SetPlotScale(0,255);
  149.   repeat
  150.     Capture;
  151.     if button then exit;
  152.     MakeLineRoi(x1,y1,x2,y2);
  153.     PlotProfile;
  154.   until button;
  155. end;
  156.  
  157.  
  158. macro 'Integrate Inverted…';
  159. {
  160. Inverts captured video to allow more than 128 frames to be
  161. integrated without overflow. For example, the sum of 256 pixels
  162. with an average value of 200(very dark) is 51,200, which is
  163. greater than the 32,767 maximum, but the sum of 256 pixels
  164. with and average value of 55(200 inverted) is 14,080.
  165. }
  166. var
  167.   nFrames:integer;
  168. begin
  169.   nFrames:=GetNumber('Number of Frames:',200);
  170.   SetVideo('Invert');
  171.   AverageFrames('Integrate',nFrames);
  172.   SetVideo(''); {Don't invert}
  173.   Invert;
  174. end;
  175.  
  176.  
  177. macro '(-' begin end; {Menu divider}
  178.  
  179. {Note: keyboard shortcuts do not work when the Video}
  180. {Control dialog box is the active window.}
  181.  
  182. macro 'SetChannel 1 [1]'; begin SetChannel(1) end;
  183. macro 'SetChannel 2 [2]'; begin SetChannel(2) end;
  184. macro 'SetChannel 3 [3]'; begin SetChannel(3) end;
  185. macro 'SetChannel 4 [4]'; begin SetChannel(4) end;
  186.  
  187. macro '(-' begin end; {Menu divider}
  188.  
  189. macro 'Set LG-3 DAC A'; begin scion[1]:=GetNumber('DAC A(0-255):',scion[1]); end;
  190. macro 'Set LG-3 DAC B'; begin scion[2]:=GetNumber('DAC B(0-255):',scion[2]); end;
  191. macro 'Set LG-3 Data Out'; begin scion[4]:=GetNumber('Data Out(0-15):',scion[4]); end;
  192. macro 'Read LG-3 Data In'; begin PutMessage('Data In=',BitAnd(scion[3],15):1); end;
  193.  
  194.  
  195.  
  196.  
  197.  
  198.